/*
 * Simon Wang
 * 2006.01.11 initial version.
 * timxzl
 * 2006.12.10 first modified
 */

#ifndef GF16_H
#define GF16_H

#include <stdlib.h>
#include <windows.h>

typedef unsigned short gf16_t;

#define GF16_ZERO ((gf16_t)0)

typedef gf16_t * gf16block_t;

void gf16_init();

#define gf16_rand() ((gf16_t)(((rand()&0xFF)<<8)+rand()&0xFF))

#define gf16_add(x, y) ((x) ^ (y))
#define gf16_sub(x, y) ((x) ^ (y))

gf16_t gf16_mul(gf16_t x, gf16_t y);

gf16_t gf16_div(gf16_t x, gf16_t y);

void gf16block_ratio_sub(DWORD block_size, gf16block_t target, gf16block_t source, gf16_t ratio);

#define gf16block_ratio_add gf16block_ratio_sub

void gf16block_div(DWORD block_size, gf16block_t target, gf16_t ratio);

//gf16block_t new_gf16block(DWORD block_size);

void gf16block_read(DWORD block_size, gf16block_t buffer, HANDLE hFin);

void gf16block_write(DWORD block_size, gf16block_t buffer, HANDLE hFout);

#endif /* end */
